package cn.yjh.server.protocol;


import cn.yjh.server.support.Request;
import cn.yjh.server.support.Response;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.alibaba.fastjson.JSON;


/**
 * @author yW0041229
 * @since 2022/1/4 17:34
 */
public class RPCProtocolHandler extends ProtocolHandler {

    Logger logger = LoggerFactory.getLogger(RPCProtocolHandler.class);

    public RPCProtocolHandler(Request request, Response response) {
        super(request,response);
    }

    @Override
    public void decode() {
        if(logger.isDebugEnabled()){
            logger.info("use {} ", this.getClass().getSimpleName());
        }
        byte[] bytes = request.getInputBuffer().array();
        Request rpcMethod = JSON.parseObject(bytes,Request.class);

    }

    @Override
    public void encode(Object o) {
        response.getOutBuffer().put(JSON.toJSONBytes(o));
    }

    @Override
    public Request buildRequest() {
        return null;
    }

    @Override
    public Response buildResponse() {
        return null;
    }
}
